/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SampleHost;
import gnu.io.CommPortIdentifier;
import gnu.io.CommPort;
import gnu.io.SerialPort;

/**
 *
 * @author Owner
 */
public class PortObject {
    private SerialPort serialPort;

    public PortObject(String portName) throws Exception {
        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
        CommPort commPort = portIdentifier.open(portName, 2000);
        if (commPort instanceof SerialPort) {
            serialPort = (SerialPort)commPort;
            serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
        }
    }

    public SerialPort getPort() {
        return serialPort;
    }
}
